window.onload=function() {
    /* 点击左边导航栏显示内容 */ 
    var layui_sides = document.querySelectorAll('.layui-nav-tree li');
    var contents=document.querySelectorAll('.layui-body>div');
    for(var i=0;i<layui_sides.length;i++) {
        layui_sides[i].setAttribute('index',i);
        layui_sides[i].addEventListener('click',function() {
            var index=this.getAttribute('index');
            console.log(index);
            for(var i=0;i<layui_sides.length;i++) {
                contents[i].style.display='none';
                layui_sides[i].style.backgroundColor=''
            }
            this.style.backgroundColor='rgb(185, 211, 236)';
            contents[index].style.display='block';
        })
    }
    /* 将日期标签设置为当前日期 */
    $(document).ready(function () {
        var time = new Date();
        var day = ("0" + time.getDate()).slice(-2);
        var month = ("0" + (time.getMonth() + 1)).slice(-2);
        var today = time.getFullYear() + "-" + (month) + "-" + (day);
        $('#date_info').val(today);
    });

    /* 验证修改密码，两次密码是否一致 */
    var oldpwd=document.querySelector('.oldpwd');
    var newpwd=document.querySelector('.newpwd');
    var pwdJudge=document.querySelector('.pwdJudge');
    newpwd.addEventListener('blur',function() {
        if(this.value!=''&&oldpwd.value!='') {
            if(this.value!=oldpwd.value) {
                pwdJudge.classList.add('wrong');
                pwdJudge.classList.remove('right');
                pwdJudge.innerHTML='两次密码输入不一致';
            } else {
                pwdJudge.classList.add('right');
                pwdJudge.classList.remove('wrong');
                pwdJudge.innerHTML='合法修改';
            }
        }
        
    })

    /* 点击保存，修改用户名 */
    var newName=document.querySelector('.username');
    var save=document.querySelector('.save');
    var uname=document.querySelector('.uname');
    save.addEventListener('click',function() {
        uname.innerHTML=newName.value;
    });

    /*双击单元格修改内容*/

}

